package com.carbohydrate42.kotlin_compose_demo.util

import android.util.Log
import android.widget.Toast
import com.carbohydrate42.kotlin_compose_demo.MainApplication

object DebugUtil {

    private const val TAG = "DebugUtil"

    fun toastException(e: Throwable?, extraMsg: String? = null) {
        toast("$extraMsg : ${e?.message}")
    }

    fun exceptionLog(e: Throwable?, extraMsg: String? = null) {
        errorLog("$extraMsg : ${e?.message}")
    }

    fun toast(text: String?) {
        Toast.makeText(MainApplication.getContext(), text ?: "", Toast.LENGTH_LONG).show()
    }

    fun toastShort(text: String?) {
        Toast.makeText(MainApplication.getContext(), text ?: "", Toast.LENGTH_SHORT).show()
    }

    fun infoLog(text: String?) {
        Log.i(TAG, text ?: "")
    }

    fun errorLog(text: String?) {
        Log.e(TAG, text ?: "")
    }

    fun debugLog(text: String?) {
        Log.d(TAG, text ?: "")
    }

    fun verboseLog(text: String?) {
        Log.v(TAG, text ?: "")
    }

    fun warnLog(text: String?) {
        Log.w(TAG, text ?: "")
    }
}